package com.hnqcgc.db;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

public class DB implements IDB{
    //加载驱动
    static {
        try {
            Class.forName("com.mysql.jdbc.Driver");
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }
    }

    public DB() {
    }

    private static final String UR="jdbc:mysql://localhost:3306/dujiaoshou";
    private static final String URNAME="root";
    private static final String PASSWORD="123456";
    static Connection conn=null;
    @Override
    public Connection getConn() throws SQLException {
        conn = DriverManager.getConnection(UR,URNAME,PASSWORD);
        return conn;
    }

    public static void main(String[] args) {
        DB b = new DB();
        try {
            System.out.println(b.getConn().isClosed());
        } catch (SQLException throwables) {
            throwables.printStackTrace();
        }
    }
}



